package com.ruoyi.web.controller.award.research;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.award.research.ResearchAwardTeacher;
import com.ruoyi.system.service.award.research.IResearchAwardTeacherService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 科研获奖教师Controller
 * 
 * @author ruoyi
 * @date 2025-08-01
 */
@RestController
@RequestMapping("/award/research/teacher")
public class ResearchAwardTeacherController extends BaseController
{
    @Autowired
    private IResearchAwardTeacherService researchAwardTeacherService;

    /**
     * 查询科研获奖教师列表
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:list')")
    @GetMapping("/list")
    public TableDataInfo list(ResearchAwardTeacher researchAwardTeacher)
    {
        startPage();
        List<ResearchAwardTeacher> list = researchAwardTeacherService.selectResearchAwardTeacherList(researchAwardTeacher);
        return getDataTable(list);
    }

    /**
     * 导出科研获奖教师列表
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:export')")
    @Log(title = "科研获奖教师", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResearchAwardTeacher researchAwardTeacher)
    {
        List<ResearchAwardTeacher> list = researchAwardTeacherService.selectResearchAwardTeacherList(researchAwardTeacher);
        ExcelUtil<ResearchAwardTeacher> util = new ExcelUtil<ResearchAwardTeacher>(ResearchAwardTeacher.class);
        util.exportExcel(response, list, "科研获奖教师数据");
    }

    /**
     * 获取科研获奖教师详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(researchAwardTeacherService.selectResearchAwardTeacherById(id));
    }

    /**
     * 新增科研获奖教师
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:add')")
    @Log(title = "科研获奖教师", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ResearchAwardTeacher researchAwardTeacher)
    {
        return toAjax(researchAwardTeacherService.insertResearchAwardTeacher(researchAwardTeacher));
    }

    /**
     * 修改科研获奖教师
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:edit')")
    @Log(title = "科研获奖教师", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ResearchAwardTeacher researchAwardTeacher)
    {
        return toAjax(researchAwardTeacherService.updateResearchAwardTeacher(researchAwardTeacher));
    }

    /**
     * 删除科研获奖教师
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:remove')")
    @Log(title = "科研获奖教师", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(researchAwardTeacherService.deleteResearchAwardTeacherByIds(ids));
    }
}
